<?php 

class voteController extends appController
{
	public function index()
	{
		
// 		$_SESSION['wxid'] = 1;
		$this->check_member();
		$config[c] = array('site_name' => "爆料-".Model('app')->get_cfg('site_name'));
		$this->assign_global($config);
		$id = $_GET['id']?$_GET['id']:0;
		
		$jsdk = Model('suipai')->get_jsdk();
		$vote = Model('suipai')->getVote($id);
		$this->assign("jsdk", $jsdk);
		$this->assign("vote", $vote);
		
		
		$this->display("index.html");
	}
	
	public function send_vote()
	{
		$res = array('error' => 1, 'content' => '');
		$info['wxid'] = $_SESSION['wxid'];
		$info['oid'] = yf_empty($_POST['danxuan'], "请选择你的选项");
		$info['vid'] = yf_empty($_POST['vid'], "页面已过期");
		$is_exist = Model('suipai')->check_is_vote($info);
		if($is_exist > 0)
		{
			$res['content'] = "你已经参加过该话题了";
			$this->showMsg($res);
		}
// 		$info['phone'] = yf_empty($_POST['phone'], "请输入手机号");
// 		if(hy_check($info['phone'], 'm') == '#@_error' && hy_check($info['phone'], 't') == '#@_error')
// 		{
// 			$res['content'] = "你输入的电话格式不正确";
// 			$this->showMsg($res);
// 		}
// 		$img = yf_empty($_POST['img'], "请上传至少一张图片");
// 		$arr = array();
// 		if(!is_array($img))
// 		{
// 			$arr[] = $img;
// 		}
// 		else
// 		{
// 			$arr = $img;
// 		}
// 		$info['pic'] = json_encode($arr);
		$info['add_time'] = yf_time();
		$id = Model('suipai')->insert_vote($info);
		if($id)
		{
			$res = array('error' => 0, 'content' => '参与成功');
		}
		else 
		{
			$res['content'] = "系统繁忙";
		}
		$this->showMsg($res);
	}
	
	
	public function del()
	{
		$id=isset($_REQUEST['id'])?$_REQUEST['id']:'';
	
		if(is_array($id))
		{
			foreach($id as $k=>$v)
			{
				$result=Model('article')->del_art($v);
			}
		}
		else
		{
			$id=intval($id);
				
			$result=Model('article')->del_art($id);
		}
		print_r(json_encode($result));
	
	}
}

?>